
import java.util.Timer;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author DoanMinhVu
 */
public class LoadIntro extends Canvas{

    private Image img;
    private Display display;
    private Displayable nextScreen;
    private int timeScreen;
    private Timer timer = new Timer();

    public LoadIntro(Display display,Displayable nextScreen,int time){
        this.display = display;
        this.nextScreen = nextScreen;
        this.timeScreen = time;
    }

    public void starIntro(){
        display.setCurrent(this);
        setFullScreenMode(true);
    }

    public void endIntro(){
        display.setCurrent(nextScreen);
    }

    protected void paint(Graphics g) {
        try{
            img = Image.createImage("/Images/Java.png");
        }
        catch(Exception ex){
        }
        g.setColor(255,255,255);
        g.fillRect(0, 0, getWidth(), getHeight());
        g.setColor(200,100,50);
        g.drawImage(img,getWidth()/2,getHeight()/2-30, g.HCENTER|g.VCENTER);
        g.drawString("Loading...",getWidth()/2-30,getHeight()/2+24, g.TOP|g.LEFT);
    }

    protected void showNotify(){
        timer.schedule(new CountDown(this), timeScreen);
    }

}
